package com.oliver.proxy.midjourney.interfaces.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

@Api(tags = "PSD文件查询")
@RestController
@RequestMapping("/api/psd-files")
public class PsdFileController {

    private static final String PSD_DIRECTORY = "/Users/oliver/pic/processing";
    private static final String PSD_EXTENSION = ".psd";

    @ApiOperation(value = "获取PSD文件名列表（不含后缀）")
    @GetMapping("/list")
    public List<String> listPsdFilenames() {
        File directory = new File(PSD_DIRECTORY);
        
        if (!directory.exists() || !directory.isDirectory()) {
            return List.of();
        }
        
        File[] files = directory.listFiles((dir, name) -> name.toLowerCase().endsWith(PSD_EXTENSION));
        
        if (files == null || files.length == 0) {
            return List.of();
        }
        
        return Arrays.stream(files)
                .map(File::getName)
                .map(name -> name.substring(0, name.length() - PSD_EXTENSION.length()))
                .collect(Collectors.toList());
    }
} 